package edu.spec.yjx.dao.impl;

import edu.spec.yjx.dao.iface.INewsDao;
import edu.spec.yjx.model.News;
import org.madgecko.basic.dao.BaseDao;
import org.madgecko.basic.kit.BasicKit;
import org.madgecko.basic.model.Pager;
import org.springframework.stereotype.Repository;

/**
 * Author       : MadFrog
 * Date         : 2018/11/10 17:55
 * Description  : 新闻数据访问接口
 */
@Repository
public class NewsDao extends BaseDao<News> implements INewsDao {
    @Override
    public Pager<News> findByCon(String keyword) {
        String hql = "from News ";
        if(!BasicKit.isEmpty(keyword)){
            hql += " where title like '%" + keyword + "%'";
        }
        hql += " order by createDate desc";
        return this.find(hql);
    }
}
